package com.wang.test.demo.putong;

import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;

public class ArrayListDemo {

    public static void main(String[] args) {

        List<String> list = new Vector<>();
        for (int x = 0; x < 20; x++) {
            new Thread(() -> {
                list.add(UUID.randomUUID().toString());
                System.out.println(list);
            },String.valueOf(x)).start();
        }

        System.out.println("+++++++++");
        Map<String, Object> map = new HashMap<>();
        //map.put("keyword","sss");
        boolean keyword = map.containsKey("keyword");
        System.out.println(keyword);
    }
    public static void CopyOnWrite(){
        List<String> list = new CopyOnWriteArrayList();
        for (int x = 0; x < 20; x++) {
            new Thread(() -> {
                list.add(UUID.randomUUID().toString());
                System.out.println(list);
            },String.valueOf(x)).start();
        }
    }
    public static void CME(){
        List<String> list = new ArrayList<>();

        for (int x = 0; x < 20; x++) {
            new Thread(() -> {
                list.add(UUID.randomUUID().toString());
                System.out.println(list);
            },String.valueOf(x)).start();
        }
    }
}
